import request from '@/utils/request';

export default {
    // 微信登录
    wxLogin(data) {
        return request.post('/user/wx-login', {
            code: data.code,
            nickname: data.userInfo.nickName,
            avatarUrl: data.userInfo.avatarUrl
        });
    },

    // 更新用户信息
    updateUserInfo(userInfo) {
        return request.post('/user/update', userInfo);
    },

    // 获取用户信息
    getUserInfo() {
        return request.get('/user/info');
    },

    // 检查登录状态
    checkLoginStatus() {
        const token = uni.getStorageSync('token');
        return !!token;
    },

    // 退出登录
    logout() {
        uni.removeStorageSync('token');
        uni.removeStorageSync('userId');
        uni.reLaunch({
            url: '/pages/home/login'
        });
    }
}; 